package com.yy.xshell.process.commandhandler;

import com.yy.xshell.process.Handler;

/**
 * 处理信号量
 * @author wxy
 * @version 1.0
 * @date 2024/8/20 15:44
 */
public class SignalQuantityHandler extends Handler<String> {

    /**
     * ctrl + c 的信号是 3, ctrl + d 的信号是 4, ctrl + x 的信号是 24
     * this.write(new byte[]{24} + '\n');
     * @param command
     * @return
     */

    private static final String pattern = ">>>Control\\+[a-z]{1}<<<";


    public String handler(String command) {
        char s = command.charAt(11);
        int c = s-97+1;
        return new String(new byte[]{(byte)c});
    }

    public boolean accept(String command) {
        return command.matches(pattern);
    }

    public static void main(String[] args) {
        String test = ">>>Control+c<<<";
        System.out.println(test.charAt(11));
    }
}
